package cn.wolfcode.education.query;

import cn.wolfcode.education.util.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter@Setter
public class RegularStuChartQuery extends QueryObject {
    //开始时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date beginDate;

    //结束时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date endDate;

    private String groupBy="sdi_college.name";//缺省的分组查询条件

    //存储了不同维度的分组查询条件
    public static Map<String,String> groupByTypes = new HashMap<String,String>();
    static{
        groupByTypes.put("sdi_college.name","所在学院");
        groupByTypes.put("sdi_campus.name","所在校区");
        groupByTypes.put("rs.classStatus","所在班级状态");
        groupByTypes.put("sdi_paymentType.name","付款方式");
    }

    private Date getEndDate(){
        return endDate != null ? DateUtil.getEndDate(endDate) : null;
    }
}
